@extends('layouts.userctl')
@section('content')
<style>
	.layui-card-header {
		margin-top: 15px;
	}

	/*.layui-table-cell {
		display: flex;
		justify-content: center;
		align-items: center;
	}*/

	.userstatus {
		margin-left: 6px;
		color: #888;
		font-size: 14px;
	}

	.layui-table-tips-c::before {
		position: absolute !important;
		top: 0;
		bottom: 0;
		left: 0;
		right: 0px !important;
		display: flex;
		justify-content: center;
		align-items: center;
	}
	.layui-table-cell{
		height: auto !important;
	}
	.laytable-cell-1-0-0 {
		display: flex;
		justify-content: center;
		align-items: center;
	}
	.comname{
		margin-left:20px;
	}
</style>
{{csrf_field()}}
<div class="layuimini-container">
	<div class="layuimini-main">
		<div style="margin: 10px 10px 10px 10px" id="btn">
			<form class="layui-form layui-form-pane" action="">
				<div class="layui-form-item">
					<div class="layui-inline" style="float: left;">
						<a class="layui-btn layui-btn-normal" href="{{route('admin.company.comlist')}}"
							style="color: #fff;">返回</a>
						<span class="comname">{{$comName}}</span>
<!--						<a href="{{ url()->previous() }}" class="layui-btn layui-btn-primary">返 回</a>-->
					</div>
				</div>
			</form>
		</div>
		<!--注意此处table标签里的id-->
		<table class="layui-table layui-hide" id="dataTable" lay-filter="dataTable"></table>
	</div>
</div>

<!-- <div class="layui-card">
	<div class="layui-card-header layuiadmin-card-header-auto">
		<a class="layui-btn layui-btn-normal" href="{{route('admin.user.adduser')}}" style="color: #fff;">新增用户</a>
	</div>
	<div class="layui-card-body">
		<table id="dataTable" lay-filter="dataTable"></table>
	</div>
</div> -->

<script>
	layui.use(['layer', 'table', 'form'], function() {
		var layer = layui.layer
	var form = layui.form
	var table = layui.table
	//用户表格初始化
	var dataTable = table.render({
			elem: '#dataTable',
			height: 'full',
			limit: 10,
			url: '/admin/work/selfentrylistdata?id={{$cid}}',
			page: true,
		cols: [
			[ //表头
				{field: 'id', title: '序 号'},
				{field: 'created', title: '自查时间'},
				{
					field: 'urlname', title: '操 作',
					templet: function (d) {
						if (d.wordsUrl) {
							return '<a class="layui-btn layui-btn-normal layui-btn-sm" lay-event="export">'+d.urlname+'</a> '  /*<a class="layui-btn layui-btn-normal layui-btn-sm" lay-event="image">图片</a>*/
						}

					}
				},

			]
		],
			done: function(response) { //定位当前table视图
				//动态监听表头高度变化，冻结行跟着改变高度
				$('.layui-table-header  tr').resize(function() {
					$('.layui-table-header  tr').each(function(index, val) {
						$($('.layui-table-fixed .layui-table-header table tr')[index])
							.height($(val).height())
				})
			})
			//初始化高度，使得冻结行表头高度一致
			$('.layui-table-header  tr').each(function(index, val) {
					$($('.layui-table-fixed .layui-table-header table tr')[index]).height($(
						val).height())
			})

			//表体部分
			//动态监听表体高度变化，冻结行跟着改变高度
			$('.layui-table-body  tr').resize(function() {
					$('.layui-table-body  tr').each(function(index, val) {
						$($('.layui-table-fixed .layui-table-body table tr')[index])
							.height($(val).height())
				})
			})
			//初始化高度，使得冻结行表体高度一致
			$('.layui-table-body  tr').each(function(index, val){
					$($('.layui-table-fixed .layui-table-body table tr')[index]).height($(val)
						.height())
			})
			var tableView = this.elem.next()

			//response.data获取后端返  回的JSON格式数据
			$.each(response.data, function(index, item) {

					//逻辑判断
					if (item.is_delete == '0') {
						//改变TR标签内字体颜色
						tableView.find('tbody tr[data-index="' + index + '"]').css('color',
							'#FF0033')
				}
				})
			}
		})
	$('#searchbtn').click(function() {
			dataTable.reload({
				where: { keyword: $('#keywordinput').val() },
				page: { curr: 1 }
			})
	})
	$(document).on('click','.smimg',function() {
		var url = $(this).attr('src')
		var img = '<img src=\'' + url +
			'\' style=\'width:800px;height:auto;max-height:800px;background-color:#fff;\'/>'
		layer.open({
			type: 1,
			title: false,
			scrollbar: false,
			area: ['800px', 'auto'],
			skin: 'layui-layer-nobg', //没有背景色
			shadeClose: true,
			content: img
		})
	})
	//监听工具条
		table.on('tool(dataTable)', function (obj) { //注：tool是工具条事件名，dataTable是table原始容器的属性 lay-filter="对应的值"
			var data = obj.data //获得当前行数据
					,
					layEvent = obj.event //获得 lay-event 对应的值
			if (layEvent === 'export') {
				location.href = data.wordsUrl
			} else if(layEvent === 'image')
			{
				location.href = '/admin/work/selfentryimages?cid=' + data.id
			}
		})
})
</script>
@endsection
